package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.base.BaseDomain;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 *    
 *    用户的实体类
 *    @author 
 *    @since 2018-11-21 21:24:23
 */
@Getter
@Setter
@Accessors(chain = true)
public class LoginInfo extends BaseDomain {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// 状态的常量
    public static final int STATE_NORMAL = 0; // 正常
    public static final int STATE_LOCK = 1; // 锁定

    // 用户类型常量
    public static final int TYPE_USER = 0; // 前端用户
    public static final int TYPE_MANAGER = 1; // 管理员

    /**
     * 登录账号
     */
    @NotEmpty(message = "{loginInfo.username.notEmpty}") // 后端校验的注解
    @Pattern(regexp = "^1[3|4|5|6|7|8|9][0-9]{9}$", message = "{loginInfo.username.pattern}")
    private String username;

    /**
     * 登录密码
     */
    @Size(min = 4, max = 16, message = "{loginInfo.password.size}")
    private String password;

    /**
     * 用户状态(正常/锁定)
     */
    private Integer state = STATE_NORMAL;

    /**
     * 用户类型(前台用户/后台用户)
     */
    private Integer userType = TYPE_USER;

    /**
     * 是否是客服
     */
    private Boolean customServiceId;

    /**
     * 是否管理员
     */
    private boolean admin;

    /**
     * 维护与角色的多对多关系
     */
    private List<Role> roles = new ArrayList<>();
}